//  Ajax JavaScript code for the shirt.html document

// The function that displays articles
function buildMenu(data) {
  var content = document.getElementById("content");
  var nextAlbum;

// Delete previous items in the color menu
  content.innerHTML = "";

// Split the data into an array of albums
  var albums = data.split('||');

// Go through the returned array of albums
  for (index = 0; index < albums.length; index++) {
    nextAlbum = albums[index];

     try {
		content.innerHTML = content.innerHTML + nextAlbum;
     }
     catch (e) {

     }
  } 
}

function getURLParameter(name) {
    alert(location.search);
    return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
}

// The function that calls bind to request data 
function getArticles() {
	var frm = $("#forma").serialize();
	var tip = getURLParameter("type");
	if (tip == null)	
		$.get("pridobiArtikle.php" + "?" + frm, function(data,status){
			buildMenu(data)
		});
	else
		$.get("pridobiArtikle.php" + "?" + frm + "&type="+ tip, function(data,status){
			buildMenu(data)
		});
}

  


